<template>
  <div>
    <van-goods-action>
      <van-goods-action-icon
        @click="isCollected = !isCollected"
        :icon="isCollected ? 'star' : 'star-o'"
        :text="isCollected ? '已收藏' : '未收藏'"
        :color="isCollected ? '#ff5000' : '#666'"
      />
      <van-goods-action-icon :badge="goodsCount" icon="cart-o" text="购物车" />
      <van-goods-action-button @click="addGoods" type="warning" text="加入购物车" />
      <van-goods-action-button @click="buy" type="danger" text="立即购买" />
    </van-goods-action>
  </div>
</template>

<script>
export default {
  props: ['goodsCount'],
  data() {
    return {
      // 是否收藏
      isCollected: false
    }
  },
  methods: {
    // 购买功能
    buy() {
      console.log('buy')
    },
    // 加入购物车
    addGoods() {
      this.$emit('addGoods')
    }
  }
};
</script>

<style lang="less" scoped>
.van-goods-action {
  z-index: 99999;
}
</style>
